package com.gzs.support.test;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;

import org.csource.fastdfs.TrackerGroup;
/**
 * 
 * @author 987
 *
 */
public class FastDFSClient {
	
	public static final int DEFAULT_CONNECT_TIMEOUT = 30 * 1000;
	public static final int DEFAULT_NETWORK_TIMEOUT = 60 * 1000;
	public static final String G_CHARSET = "UTF-8";
    
	public int g_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
	public int g_network_timeout = DEFAULT_NETWORK_TIMEOUT;
	public String g_charset = G_CHARSET;
	
	public int g_tracker_http_port;
	public boolean g_anti_steal_token;
	public String g_secret_key;
	public TrackerGroup g_tracker_group;
	  
	public FastDFSClient() {
	}
	  
	public Socket getSocket(String ip_addr, int port)
			throws IOException{
		Socket sock = new Socket();
		sock.setSoTimeout(g_network_timeout);
		sock.connect(new InetSocketAddress(ip_addr, port), g_connect_timeout);
		return sock;
	}
	  
	public Socket getSocket(InetSocketAddress addr)
			throws IOException{
		Socket sock = new Socket();
		sock.setSoTimeout(g_network_timeout);
		sock.connect(addr, g_connect_timeout);
		return sock;
	}
	  
	public int getG_connect_timeout(){
		return g_connect_timeout;
	}
	  
	public void setG_connect_timeout(int connect_timeout){
		g_connect_timeout = connect_timeout;
	}
	  
	public int getG_network_timeout(){
		return g_network_timeout;
	}
	  
	public void setG_network_timeout(int network_timeout){
		g_network_timeout = network_timeout;
	}
	  
	public String getG_charset(){
		return g_charset;
	}
	  
	public void setG_charset(String charset){
		g_charset = charset;
	}
	  
	public int getG_tracker_http_port(){
		return g_tracker_http_port;
	}
	  
	public void setG_tracker_http_port(int tracker_http_port){
		g_tracker_http_port = tracker_http_port;
	}
	  
	public boolean getG_anti_steal_token(){
		return g_anti_steal_token;
	}
	  
	public boolean isG_anti_steal_token(){
		return g_anti_steal_token;
	}
	  
	public void setG_anti_steal_token(boolean anti_steal_token){
		g_anti_steal_token = anti_steal_token;
	}
	  
	public String getG_secret_key(){
		return g_secret_key;
	}
	  
	public void setG_secret_key(String secret_key){
		g_secret_key = secret_key;
	}
	  
	public TrackerGroup getG_tracker_group(){
		return g_tracker_group;
	}
	  
	public void setG_tracker_group(TrackerGroup tracker_group){
		g_tracker_group = tracker_group;
	}
}

